/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _OLA_DEF_H_
#define _OLA_DEF_H_

#ifdef __cplusplus
extern "C" {
#endif

#define OLA_VERSION     "1.0"

#ifndef CFG_SDK_VER
#define CFG_SDK_VER "SDK version unknow"
#endif

#define OLA_IP_IPV4_LEN 16
#define OLA_IP_IPV6_LEN 40
#define OLA_IP_LEN      OLA_IP_IPV6_LEN
#define OLA_INVALID_IP  "0.0.0.0"
#define OLA_INVALID_FD  (-1)

#define OLA_UDID_HEX_LEN            64
#define OLA_UDID_BYTE_LEN           32
#ifdef OLA_DEBUG
#define OLA_DEV_AUTH_CHALLENGE_LEN  64 // TODO：challenge长度非标
#else
#define OLA_DEV_AUTH_CHALLENGE_LEN  32
#endif
#define OLA_DEV_AUTH_HC_LEN         128
#define OLA_DEV_AUTH_RS_LEN         4
#define OLA_DEV_AUTH_HS_LEN         64
#define OLA_DEV_AUTH_RC_LEN         8
#define OLA_DEV_AUTH_PSK_LEN        64
#define OLA_MS_PER_SECOND           1000
#define OLA_DEV_REGISTER_DEVID_LEN  40
#define OLA_DEV_REGISTER_SECRET_LEN 40
#define OLA_MD_HMAC_LEN             32
#define OLA_SHA256_HEX_LEN          32
#define OLA_SHA256_STRING_LEN       64
#define OLA_DEV_REGISTRY_CODE_LEN   32
#define OLA_DEV_TICKET_LEN          32
#define OLA_DEV_CLOUD_URL_LEN       256
#define OLA_DEV_WIFI_INFO_FLAG_LEN  1
#define OLA_TYPICAL_GCM_TAG_LEN     16
#define OLA_TYPICAL_GCM_IV_LEN      12
#define OLA_TYPICAL_GCM_VERSION_LEN 1
#define OLA_TYPICAL_GCM_VERSION     0
#define COAP_TCP_PKT_LEN            2

#define OLA_STRING_ERRCODE          "errcode"
#define OLA_STRING_UDID             "udid"
#define OLA_STRING_RC               "Rc"
#define OLA_STRING_HC               "Hc"
#define OLA_STRING_RS               "Rs"
#define OLA_STRING_HS               "Hs"
#define OLA_STRING_CHALLENGE        "challenge"
#define OLA_STRING_CERT_CHAIN       "certChain"
#define OLA_STRING_SIGNATRUE        "signature"
#define OLA_STRING_SSID             "ssid"
#define OLA_STRING_PASSWORD         "password"
#define OLA_STRING_CLOUD_URL        "cloudUrl"
#define OLA_STRING_PSK              "psk"
#define OLA_STRING_REGISTRY_CODE    "registryCode"
#define OLA_STRING_TICKET           "ticket"
#define OLA_STRING_CERITIFY_KEY     "K"
#define OLA_STRING_SN               "sn"
#define OLA_STRING_MODEL            "model"
#define OLA_STRING_DEV_TYPE         "devType"
#define OLA_STRING_MANU             "manu"
#define OLA_STRING_DEV_NAME         "devName"
#define OLA_STRING_PROD_ID          "prodId"
#define OLA_STRING_VERSION          "version"
#define OLA_STRING_MAC              "mac"
#define OLA_STRING_FWV              "fwv"
#define OLA_STRING_HWV              "hwv"
#define OLA_STRING_SWV              "swv"
#define OLA_STRING_PROT_TYPE        "protType"
#define OLA_STRING_DEVID            "devId"
#define OLA_STRING_VERSION_UPPER    "Version"
#define OLA_STRING_SECRET           "secret"
#define OLA_STRING_VENDOR_ID        "vendorID"
#define OLA_STRING_DEVICENAME       "devName"
#define OLA_STRING_CAT_ID           "catID"
#define OLA_STRING_PRODUCTID        "productId"
#define OLA_STRING_DEV_AUTH         "DevAuth"
#define OLA_STRING_SER_AUTH         "SerAuth"
#define OLA_STRING_OPCODE           "EncKey"
#define OLA_STRING_ACCESS_TOKEN     "accessToken"
#define OLA_STRING_REFRESH_TOKEN    "refreshToken"
#define OLA_STRING_TIMEOUT          "timeout"
#define OLA_STRING_DEV_INFO         "devInfo"
#define OLA_STRING_TIMESTAMP        "timestamp"
#define OLA_STRING_TIMEZONE         "timezone"

#define OLA_STRING_TYPE             "type"
#define OLA_STRING_INFO             "info"
#define OLA_STRING_ECDH             "ecdh"
#define OLA_STRING_MODE             "mode"
#define OLA_STRING_MODES            "modes"
#define OLA_STRING_RANDOM           "random"
#define OLA_STRING_CURVE_SUITE      "curve_suite"
#define OLA_STRING_CURVE_SUITES     "curve_suites"
#define OLA_STRING_SIGN_SUITE       "sign_suite"
#define OLA_STRING_SIGN_SUITES      "sign_suites"
#define OLA_STRING_OOB              "oob"
#define OLA_STRING_EXTENTS          "extents"
#define OLA_STRING_SIGN             "sign"
#define OLA_STRING_PUBLICK_KEY      "public_key"
#define OLA_STRING_CERTS            "certs"
#define OLA_STRING_IV               "iv"
#define OLA_STRING_STEP             "step"

#define OLA_STRING_SESSIONID        "sessionId"
#define OLA_STRING_SECURITYDT       "securityData"
#define OLA_STRING_PAYLOAD          "payload"
#define OLA_STRING_MESSAGE          "message"
#define OLA_STRING_ERROR_CODE       "errorCode"

#define OLA_COAP_OPTION_JSON        "application/json"

#define PROVISIONING_COAP_PROT      5683
#define CLOUD_COAP_PORT             15683

/* TODO app当前spekeuri非标 */
#ifdef OLA_DEBUG
#define OLA_COAP_URI_SPEKE_START        "SPEKE"
#else
#define OLA_COAP_URI_SPEKE_START        "ola/v1/device/spekeStart"
#endif
#define OLA_COAP_URI_SPEKE_FINISH       "ola/v1/device/spekeFinish"
#define OLA_COAP_URI_PECDH_URI          ".sys/handshake"
#define OLA_COAP_URI_JPAKE_URI          ".sys/jpake"
#define OLA_COAP_URI_PROVISIONING       "ola/v1/device/provisioning"
/* TODO：app当前认证uri非标 */
#ifdef OLA_DEBUG
#define OLA_COAP_URI_DEVICE_AUTH        "ola/v1/device/challenge"
#define OLA_COAP_URI_CLOUD_CERTIFY      "ola/v1/device/auth"
#else
#define OLA_COAP_URI_DEVICE_AUTH        "ola/v1/device/auth"
#define OLA_COAP_URI_CLOUD_CERTIFY      "ola/v1/device/certify"
#endif
#define OLA_COAP_URI_REGISTER           "ola/v1/device/register"
#define OLA_COAP_URI_LOGIN              "ola/v1/device/login"
#define OLA_COAP_URI_SERVICES           "ola/v1/device/services"
#define OLA_COAP_URI_PROPERTIES_REPORT  "ola/v1/device/properties/notify"
#ifdef OLA_DEMO_TEST
#define OLA_COAP_URI_PROPERTIES_QUERY   "ola/v1/device/properties"
#else
#define OLA_COAP_URI_PROPERTIES_QUERY   "ola/v1/device/properties/query"
#endif
#define OLA_COAP_URI_PROPERTIES_CONTROL "ola/v1/device/properties/control"
#define OLA_COAP_URI_HEARTBEAT          "ola/v1/device/heartbeat"
#define OLA_COAP_URI_TOKEN_REFRESH      "ola/v1/device/tokenRefresh"

#define OLA_STRING_MAIN_TASK_NAME   "ola_main_task"

#ifdef __cplusplus
}
#endif

#endif /* _OLA_DEF_H_ */